package org.cargloss.cp.controller.modul.menus;

import java.util.List;

import org.cargloss.cp.model.Menus;

import util.hibernate.DAO;

public class MenuBean {
	private List<Menus> listMenu;
	private List<Menus> listSubMenu;

	public List<Menus> getListMenu() {
		return listMenu;
	}

	public void setListMenu(List<Menus> listMenu) {
		this.listMenu = listMenu;
	}

	public List<Menus> getListSubMenu() {
		return listSubMenu;
	}

	public void setListSubMenu(List<Menus> listSubMenu) {
		this.listSubMenu = listSubMenu;
	}

	@SuppressWarnings({ "unused", "unchecked" })
	private void populateMenu() {
		DAO<Integer> dao = new DAO<Integer>();
		DAO<Integer> dao2 = new DAO<Integer>();
		dao.createCriteria(Menus.class);
		dao.addFilter("isNull", "parent.id", 0);
		dao.addOrder("asc", "id");
		dao.addOrder("asc", "parent");
		listMenu = (List<Menus>) dao.find();

		dao2.createCriteria(Menus.class);
		dao2.addFilter("gt", "parent.id", 0);
		dao2.addOrder("asc", "id");
		dao2.addOrder("asc", "parent");
		listSubMenu = (List<Menus>) dao2.find();

		dao.close();
	}
}
